﻿using UnityEngine;
using UnityEngine.EventSystems;

// 点击拽UI
public class DragUI : MonoBehaviour, IDragHandler, IPointerDownHandler {

    private Vector2 _offsetPos;  //临时记录点击点与UI的相对位置

    public void OnDrag(PointerEventData eventData)
    {
        transform.position = eventData.position - _offsetPos;
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        _offsetPos = eventData.position - (Vector2)transform.position;
    }
}